package com.amu.aidemo.android.zhipu

import com.google.gson.annotations.SerializedName

/**
 * Zhipu AI Chat Completion Request
 */
data class ZhipuChatRequest(
    @SerializedName("model")
    val model: String = "glm-4.6",
    
    @SerializedName("messages")
    val messages: List<ZhipuMessage>,
    
    @SerializedName("stream")
    val stream: Boolean = true,
    
    @SerializedName("temperature")
    val temperature: Float = 0.8f,
    
    @SerializedName("top_p")
    val topP: Float = 0.95f,
    
    @SerializedName("max_tokens")
    val maxTokens: Int = 2048,
    
    @SerializedName("request_id")
    val requestId: String? = null
)

/**
 * Message in conversation
 */
data class ZhipuMessage(
    @SerializedName("role")
    val role: String, // "system", "user", "assistant"
    
    @SerializedName("content")
    val content: String
)

/**
 * Non-streaming response
 */
data class ZhipuChatResponse(
    @SerializedName("id")
    val id: String,
    
    @SerializedName("created")
    val created: Long,
    
    @SerializedName("model")
    val model: String,
    
    @SerializedName("choices")
    val choices: List<ZhipuChoice>,
    
    @SerializedName("usage")
    val usage: ZhipuUsage?
)

/**
 * Choice in response
 */
data class ZhipuChoice(
    @SerializedName("index")
    val index: Int,
    
    @SerializedName("message")
    val message: ZhipuMessage?,
    
    @SerializedName("delta")
    val delta: ZhipuDelta?,
    
    @SerializedName("finish_reason")
    val finishReason: String?
)

/**
 * Delta for streaming response
 */
data class ZhipuDelta(
    @SerializedName("role")
    val role: String?,
    
    @SerializedName("content")
    val content: String?
)

/**
 * Token usage statistics
 */
data class ZhipuUsage(
    @SerializedName("prompt_tokens")
    val promptTokens: Int,
    
    @SerializedName("completion_tokens")
    val completionTokens: Int,
    
    @SerializedName("total_tokens")
    val totalTokens: Int
)

/**
 * Error response
 */
data class ZhipuErrorResponse(
    @SerializedName("error")
    val error: ZhipuError
)

data class ZhipuError(
    @SerializedName("code")
    val code: String,
    
    @SerializedName("message")
    val message: String
)
